package aroundadvice.around;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

//通知类  环绕通知类
public class MyAroundInterceptors implements MethodInterceptor {

    //执行的额外功能  参数：切到的目标对象 具体方法，方法的参数...
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {

        //获取开始时间
        long startTime = System.currentTimeMillis();

        //额外功能
        System.out.println("===1===开启事务");

        Object result = invocation.proceed();//放行环绕通知 执行目标方法

        System.out.println("===3===关闭事务");

        //获取结束时间
        long endTime = System.currentTimeMillis();

        System.out.println("执行时间为："+(endTime-startTime)+"ms");

        return result;
    }
}
